package com.mao.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Author: Administrator
 * Date: 2021/7/8 20:48
 * Description:
 */

/**
 * 1、找对象
 * 2、放到 spring 中待用！
 * 3、如果是 SpringBoot 就先分析源码
 */
@Configuration
public class ElasticSearchConfig {


    /**
     * 自定义配置类的话应该要注意方法名
     * <bean id="restHighLevelClient" class="RestHighLevelClient" />
     * @return
     */
    @Bean
    public RestHighLevelClient restHighLevelClient(){
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost("127.0.0.1",9200,"http")
                )
        );
    }
}

